<?php
$form = $this->beginWidget('CActiveForm', array(
    'id'    => 'newsletter-content-form',
//    'enableAjaxValidation'   => true,
//    'enableClientValidation' => true,
    'focus' => array($model, 'title'),
    'errorMessageCssClass' => 'error',
    'htmlOptions'          => array(
        'enctype' => 'multipart/form-data',
        'class'   => 'form',
    ),
));

echo $form->hiddenField($model, 'folder_id');
?>

<fieldset>
    <ul>
        <li>
            <?php echo $form->labelEx($model, 'type_id', array('class'    => 'desc')); ?>

            <div>
                <?php
                $data      = DNewsletterType::model()->getMenu(true);
                $attribute = 'type_id';

                $this->widget('ArrayToDropDownList', array(
                    'model'         => $model,
                    'attribute'     => $attribute,
                    'data'          => $data,
                    'disableParent' => true,
                    'selected'      => $model->getAttribute('type_id'),
                    'htmlOptions'   => array(
                        'class'    => 'select',
                    ),
                ));
                ?>
            </div>
        </li>

        <li>
            <?php
            $attribute = 'title';
            echo $form->labelEx($model, $attribute, array('class' => 'desc'));
            ?>

            <div>
                <?php
                echo $form->textField($model, $attribute, array(
                    'class' => 'text large',
                ));

                $attribute = 'activated_flag';
                echo $form->checkbox($model, $attribute, array(
                    'style' => 'display:inline-block;',
                ));
                echo CHtml::label($model->getAttributeLabel($attribute), 'DNewsletterContent_activated_flag', array(
                    'style' => 'display:inline-block; font-weight:900;',
                    'class' => 'desc',
                ));

                echo $form->error($model, 'title');
                ?>
            </div>
        </li>

        <li>
            <?php
            $attribute = 'short_content';
            echo $form->labelEx($model, $attribute, array('class' => 'desc'));
            ?>

            <div>
                <?php
                $this->widget('ext.ckeditor.CKEditorWidget', array(
                    'model'     => $model,
                    'attribute' => $attribute,
                    'config'    => array(
                        'height'   => 100,
                    ),
                ));
                
                echo $form->error($model, $attribute);
                ?>
            </div>
        </li>

        <li>
            <?php
            $attribute = 'detailed_content';
            echo $form->labelEx($model, 'detailed_content', array('class' => 'desc'));
            ?>

            <div>
                <?php
                $this->widget('ext.ckeditor.CKEditorWidget', array(
                    'model'     => $model,
                    'attribute' => $attribute,
                    'config'    => array('toolbar' => 'DFull',),
                    'folderID' => $model->folder_id,
                ));
                
                echo $form->error($model, $attribute);
                ?>
            </div>
        </li>

        <li>
            <?php
            $attribute = 'file';
            echo $form->labelEx($model, 'file', array('class' => 'desc'));
            ?>

            <div>
                <?php
                echo $form->fileField($model, $attribute);
                echo $form->error($model, $attribute);
                if ($model->getAttribute($attribute) != '') {
                    echo CHtml::checkBox('deleteFileFlag', false);
                    echo '<span class="inline">Delete</span>';
                    echo CHtml::hiddenField('uploadedFileFlag', $model->getAttribute($attribute));
                }
                ?>
            </div>
        </li>

        <li>
            <?php
            $attribute = 'keyword';
            echo $form->labelEx($model, $attribute, array('class' => 'desc'));
            ?>

            <div>
                <?php
                echo $form->textField($model, $attribute, array('class' => 'text large'));
                echo $form->error($model, $attribute);
                ?>
            </div>
        </li>

        <li>
            <?php
            $attribute = 'description';
            echo $form->labelEx($model, $attribute, array('class' => 'desc'));
            ?>
            <div>
                <?php
                echo $form->textField($model, $attribute, array('class' => 'text large'));
                echo $form->error($model, $attribute);
                ?>
            </div>
        </li>

        <li style="text-align: center;">
            <?php
            $label = Yii::t('DadminModule.app', 'save_u');
            echo CHtml::submitButton($label, array(
                'class' => 'ui-state-default ui-corner-all ui-button'
            ));
            
            $label = Yii::t('DadminModule.app', 'reset_u');
            echo CHtml::button($label, array(
                'id'    => 'btn-reset',
                'class' => 'ui-state-default ui-corner-all ui-button',
                'style' => 'margin:0 10px;',
            ));
            
            $label = Yii::t('DadminModule.app', 'cancel_u');
            echo CHtml::button($label, array(
                'class' => 'ui-state-default ui-corner-all ui-button btn-cancel'
            ));
            ?>
        </li>
    </ul>
</fieldset>
<?php $this->endWidget(); ?>

<div id="imageDialogContainer" style="display:none;"></div>